package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.resource.*;
import com.mingqijia.gassafety.authority.api.resp.resource.OperationRespDTO;
import com.mingqijia.gassafety.authority.api.resp.resource.ResourceLiteRespDTO;
import com.mingqijia.gassafety.authority.api.resp.resource.ResourceRespDTO;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 资源管理接口方法
 * @author Damon S.
 * @version v1.0.1
 * @date 2020年05月27日 22:49
 */
@Api(tags = "控制台--资源(菜单)")
@RequestMapping(value = "/console/v1/resources", produces = MediaType.APPLICATION_JSON_VALUE)
public interface ResourceManageFacade {

    /**
     * 查询资源
     * @param req 查询参数
     * @return 返回值
     */
    @GetMapping
    @ApiOperation(value = "查询资源(菜单)", notes = "返回资源列表")
    PageUtil<ResourceRespDTO> findResource(@Valid QueryResourceReqDTO req);


    @GetMapping("/hierarchy")
    @ApiOperation(value = "获取资源(菜单)树", notes = "返回资源列表")
    List<ResourceLiteRespDTO> buildHierarchy();

    /**
     * 新增菜单资源
     * @param req 新增菜单资源请求参数
     * @return 返回新增资源信息
     */
    @PostMapping
    @ApiOperation(value = "新增资源(菜单)", notes = "返回是否创建成功")
    String createResource(@RequestBody @Valid CreateMenuResourceReqDTO req);

    /**
     * 新增按钮资源
     * @param req 新增按钮资源请求参数
     * @return 返回新增资源信息
     */
    @PostMapping("/functions")
    @ApiOperation(value = "新增资源(按钮)", notes = "返回是否创建成功")
    String createResource(@RequestBody @Valid CreateFuncResourceReqDTO req);

    /**
     * 更新菜单
     * @param req 更新资源请求参数
     * @return 返回更新资源后的信息
     */
    @PutMapping
    @ApiOperation(value = "更新资源(菜单)", notes = "返回是否更新成功")
    void updateResource(@RequestBody @Valid UpdateMenuResourceReqDTO req);

    /**
     * 更新按钮
     * @param req 更新资源请求参数
     * @return 返回更新资源后的信息
     */
    @PutMapping("/functions")
    @ApiOperation(value = "更新资源(按钮)", notes = "返回是否更新成功")
    void updateResource(@RequestBody @Valid UpdateFuncResourceReqDTO req);


    @DeleteMapping("/{resId}")
    @ApiImplicitParam(name = "resId", value = "资源Id列表", dataType = "Array")
    @ApiOperation(value = "删除资源", notes = "返回是否删除成功")
    void removeResource(String[] resId);


    @PutMapping("/{resId}/{state}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "resId", value = "资源Id", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "启用状态", dataType = "String")
    })
    @ApiOperation(value = "资源上下线(0停用，1启用)", notes = "返回是否成功")
    void switchResource(@PathVariable String resId, @PathVariable Integer state);


    @GetMapping("/functions")
    @ApiOperation(value = "获取资源(菜单)功能列表", notes = "返回资源操作列表")
    List<OperationRespDTO> getFunctions();
}
